package com.supreme.stockserver.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.supreme.commonmybatis.mapper.AccountMapper;
import com.supreme.commonmybatis.entity.primary.MBAccount;
import com.supreme.commonboot.utils.AjaxResp;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "account")
public class AccountController {

    @Resource
    private AccountMapper accountMapper;

    @GetMapping(value = "search")
    public AjaxResp searchAccount() {
        QueryWrapper<MBAccount> queryWrapper = new QueryWrapper<>();
        List<MBAccount> accountList = this.accountMapper.selectList(queryWrapper);
        return new AjaxResp(accountList);
    }

    @PostMapping(value = "create")
    public AjaxResp createAccount(@RequestBody MBAccount account) {
        int insert = this.accountMapper.insert(account);
        return new AjaxResp(insert);
    }
}
